﻿using System;
using Infrastucture;

namespace TimeSplicerModule.DomainModels
{
    public class TimestampModel : DomainObject
    {
        private Guid _timestampGuid;
        private Guid _taskGuid;
        private int _stampNumber;
        private DateTime _startTime;
        private DateTime _endTime;
        private string _timestampTypeEnum;
        private TimestampType _timeStampType;
        private double _hours;


        public Guid TimestampGuid
        {
            get { return _timestampGuid; }
            set { SetProperty(ref _timestampGuid, value); }
        }
        public Guid TaskGuid
        {
            get { return _taskGuid; }
            set { SetProperty(ref _taskGuid, value); }
        }
        public int StampNumber
        {
            get { return _stampNumber; }
            set { SetProperty(ref _stampNumber, value); }
        }
        public DateTime StartTime
        {
            get { return _startTime; }
            set { SetProperty(ref _startTime, value); }
        }
        public DateTime EndTime
        {
            get { return _endTime; }
            set { SetProperty(ref _endTime, value); }
        }
        public string EndTimeString
        {
            get
            {
                return this.EndTime > DateTime.Parse("1/1/2000") ? String.Format("{0:MM/dd/yyyy hh:mm:ss tt}", this.EndTime) : "";
            }
        }
        public string TimestampTypeEnum
        {
            get { return _timestampTypeEnum; }
            set 
            { 
                SetProperty(ref _timestampTypeEnum, value);

                if (this.TimestampType.ToString() != value)
                    this.UpdateEnumeration<TimestampType>("TimestampType", value);
            }
        }
        public TimestampType TimestampType
        {
            get { return _timeStampType; }
            set
            {
                SetProperty(ref _timeStampType, value);
                this.UpdateEnumerationString<TimestampType>("TimestampTypeEnum", value);
            }
        }
        [DoNotConvert]
        public double Hours 
        {
            get { return (this.EndTime >= this.StartTime) ? Math.Round(this.EndTime.Subtract(this.StartTime).TotalHours, 2) : 0; } 
        }
    }
}
